home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-debian / examples / debfile / changelog_head < prev    next >
Encoding:
Text File  |  2008-08-09  |  991 b   |  36 lines

  1. #!/usr/bin/python
  2.  
  3. # changelog_head - head like tool for .deb changelog entries
  4. # Copyright (C) 2007 Stefano Zacchiroli <zack@debian.org>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10.  
  11. """Like "head" for changelog entries, return last n-th entries of the changelog
  12. shipped in a .deb file."""
  13.  
  14. import string
  15. import sys
  16.  
  17. from debian_bundle import debfile
  18.  
  19. if __name__ == '__main__':
  20.     if len(sys.argv) > 3 or len(sys.argv) < 2:
  21.         print "Usage: changelog_head DEB [ENTRIES]"
  22.         print "  ENTRIES defaults to 10"
  23.         sys.exit(1)
  24.  
  25.     entries = 10
  26.     try:
  27.         entries = int(sys.argv[2])
  28.     except IndexError:
  29.         pass
  30.  
  31.     deb = debfile.DebFile(sys.argv[1])
  32.     chg = deb.changelog()
  33.     entries = chg._blocks[:entries]
  34.     print string.join(map(str, entries), '')
  35.  
  36.